package com.bjpowernode.servlets;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class SomeServlet extends HttpServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		// 获取请求的URL
		StringBuffer requestURL = request.getRequestURL();
		System.out.println("requestURL = " + requestURL);
		
		// 获取请求的URI：URL去掉请求协议及主机后的剩余部分
		String requestURI = request.getRequestURI();
		System.out.println("requestURI = " + requestURI);
		
		// 获取当前Web应用的根路径
		String contextPath = request.getContextPath();
		System.out.println("contextPath = " + contextPath);
		
		// 获取客户端IP
		String clientIP = request.getRemoteAddr();
		System.out.println("clientIP = " + clientIP);
		
		
		String servletPath = request.getServletPath();
		System.out.println("servletPath = " + servletPath);
		
		String pathInfo = request.getPathInfo();
		System.out.println("pathInfo = " + pathInfo);
		
	}

}

















